package com.orange.util;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import android.content.Context;
import android.provider.BaseColumns;

import com.orange.lswidget.widgets.event.dao.UnreadSMSDao;

public class UnreadSMSUtils implements BaseColumns {
	private static final String	RECIPIENT_IDS	= "recipient_ids";

	public static boolean isUnreadSMSFromSameSender(Context context,
			List<Map<String, String>> resultList) {
		List<String> numbers = getNumbersByResult(context, resultList);
		if (null != numbers && !numbers.isEmpty()) {
			return numbers.size() == 1;
		} else {
			return true;
		}
	}

	public static List<String> getNumbersByResult(Context context,
			List<Map<String, String>> resultList) {
		List<String> ret = new ArrayList<String>();
		String number = null;
		String recipient_ids = null;
		UnreadSMSDao mMsgDao = new UnreadSMSDao(context);
		for (int count = 0; count < resultList.size(); count++) {
			Map<String, String> tempMap = resultList.get(count);
			recipient_ids = tempMap.get(RECIPIENT_IDS);
			number = mMsgDao.getSmsNumber(recipient_ids);
			ret.add(number);
		}
		return ret;
	}

}
